﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;

namespace Jarvis.Sensors
{
    public class Sensor
    {
        public string name = "Generic Sensor";
        private UInt32 interval = 1000;

        protected Timer updateTimer;

        public Sensor(string name)
        {
            this.name = name;
        }

        public Sensor()
        {
            this.updateTimer = new Timer(new TimerCallback(this.Sense), null, 0, this.interval);
        }

        public Sensor(UInt32 interval)
        {
            this.interval = interval;
            this.updateTimer = new Timer(new TimerCallback(this.Sense), null, 0, this.interval);
        }

        public virtual void Sense(Object stateInfo)
        {
            this.log("Default reading");
        }

        public void log(object reading)
        {
            if (SensorNotifier.Instance != null)
                SensorNotifier.Instance.addUpdate(this, reading);
        }
    }
}
